﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true"
    CodeBehind="Category.aspx.cs" Inherits="SharingCenter.Web.Admin.Posts.Category" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitlePlaceHolder" runat="server">
    分享园区类别管理
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script src="Post.js" type="text/javascript"></script>
    <h2>
        分享园区版块管理</h2>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="tb-full"
        DataKeyNames="PostCategoryId" DataSourceID="LinqDataSource1" GridLines="None"
        RowStyle-VerticalAlign="Top">
        <RowStyle VerticalAlign="Top"></RowStyle>
        <Columns>
            <%--<asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"  ValidationGroup="edit"
                        CommandName="Update" Text="确定"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="取消"></asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="编辑"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>--%>
            <asp:BoundField DataField="TotalThreads" HeaderText="帖数" ReadOnly="True" SortExpression="TotalThreads" />
            <asp:TemplateField HeaderText="版块名称" SortExpression="CategoryName">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("CategoryName") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ValidationGroup="edit" ID="RequiredFieldValidator12"
                        runat="server" ControlToValidate="TextBox3" ErrorMessage="*"></asp:RequiredFieldValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink1" runat="server" ToolTip="查看话题列表" NavigateUrl='<%#Eval("PostCategoryId", "List.aspx?c={0}") %>'>
                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("CategoryName") %>'></asp:Label>
                    </asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="描述" SortExpression="Description">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" Rows="5" Text='<%# Bind("Description") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ValidationGroup="edit" ID="RequiredFieldValidator13"
                        runat="server" ControlToValidate="TextBox2" ErrorMessage="*"></asp:RequiredFieldValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" ToolTip='<%# Bind("Description") %>' Text='<%# (Eval("Description").ToString().Length>15) ? (Eval("Description").ToString().Substring(0,15)+"...") : Eval("Description") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="序号" SortExpression="OrderId">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" CssClass="tb-s" runat="server" Text='<%# Bind("OrderId") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ValidationGroup="edit" ID="RequiredFieldValidator14"
                        runat="server" ControlToValidate="TextBox1" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator14" runat="server"
                        ErrorMessage="错误的数字格式" ControlToValidate="TextBox1" ValidationGroup="edit" Display="Dynamic"
                        ValidationExpression="^-?[0-9]{1,3}$"></asp:RegularExpressionValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("OrderId") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CheckBoxField DataField="Enabled" HeaderText="是否可见" SortExpression="Enabled" />
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink2" runat="server" ToolTip='<%# Eval("CategoryName", "编辑{0}") %>'
                        NavigateUrl='<%# Eval("PostCategoryId", "CatDefault.aspx?c={0}") %>'>编辑</asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>
            <myuc:MessageBox MessageType="Warning" Text="目前没有讨论版块，请在下方添加。" runat="server" />
        </EmptyDataTemplate>
    </asp:GridView>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="SharingCenter.Web.Classes.scDataContext"
        EnableInsert="True" EnableUpdate="True" TableName="Sc_PostCategories" OrderBy="OrderId"
        Where="ContextType == @ContextType">
        <WhereParameters>
            <asp:Parameter Name="ContextType" Type="Object" />
        </WhereParameters>
    </asp:LinqDataSource>
    <br />
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="PostCategoryId" DataSourceID="LinqDataSource1"
        DefaultMode="Insert" Width="100%">
        <InsertItemTemplate>
            <h2 class="bb">
                增加讨论版块</h2>
            <div class="formtable">
                <table cellspacing="0">
                    <tr>
                        <td>
                            版块名称:
                        </td>
                        <td>
                            <asp:TextBox ID="CategoryNameTextBox" runat="server" Text='<%# Bind("CategoryName") %>' />
                            <asp:RequiredFieldValidator ValidationGroup="new" ID="RequiredFieldValidator1" runat="server"
                                ControlToValidate="CategoryNameTextBox" ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top">
                            描述:
                        </td>
                        <td valign="top">
                            <asp:TextBox ID="DescriptionTextBox" runat="server" TextMode="MultiLine" Rows="5"
                                Text='<%# Bind("Description") %>' />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="DescriptionTextBox"
                                ValidationGroup="new" ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            序号:
                        </td>
                        <td>
                            <asp:TextBox ID="OrderIdTextBox" CssClass="tb-s" runat="server" Text='<%# Bind("OrderId") %>'
                                OnLoad="OrderIdTextBox_Load" />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="OrderIdTextBox"
                                ValidationGroup="new" ErrorMessage="*"></asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="错误的数字格式"
                                ControlToValidate="OrderIdTextBox" ValidationGroup="new" ValidationExpression="^-?[0-9]{1,3}$"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            是否可见:
                        </td>
                        <td>
                            <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Enabled") %>' OnLoad="CheckBox1_Load" />
                        </td>
                    </tr>
                </table>
                <div class="actionarea">
                    <asp:LinkButton ID="LinkButton1" runat="server" ValidationGroup="new" CssClass="submitbutton"
                        CommandName="Insert">确定</asp:LinkButton>
                </div>
            </div>
        </InsertItemTemplate>
    </asp:FormView>
</asp:Content>
